package pl.itconsus.model.entities;

import java.io.Serializable;
import java.util.Calendar;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Index;
import org.hibernate.validator.constraints.Email;

import pl.itconsus.model.entities.utils.BaseHistoryEntity;
import pl.itconsus.model.enumerations.UserStatus;

@Entity
@Table(name = "web_user")
public class WebUser extends BaseHistoryEntity<String> implements Serializable {

	private static final long serialVersionUID = -6260788585686718265L;

	private String email;
	private String password;
	private Calendar creationTime = Calendar.getInstance();
	private UserStatus userStatus = UserStatus.NOT_VERIFIED;

	@Transient
	@Override
	public String getId() {
		return email;
	}

	@Basic
	@Id
	@Index(name = "email_idx")
	@Column(name = "email", length = 30)
	@Email
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Basic
	@Column(name = "password", length = 50)
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Basic
	@Column(name = "creation_time", length = 12)
	@Temporal(TemporalType.TIMESTAMP)
	public Calendar getCreationTime() {
		return creationTime;
	}

	public void setCreationTime(Calendar creationTime) {
		this.creationTime = creationTime;
	}

	@Basic
	@Column(name = "user_status", length = 30)
	@Enumerated(EnumType.STRING)
	public UserStatus getUserStatus() {
		return userStatus;
	}

	public void setUserStatus(UserStatus userStatus) {
		this.userStatus = userStatus;
	}

}
